import { requestToData, commonRequest } from '@/api/commonHttp';

// 商品新增|准入 - 选择品牌 - 获取信息列表
export const getBrandInfoListService = (data, loadingFn) => commonRequest({
  url: '/sysback/addsingleproduct/basicinfo/getPagerByBrandAndCategory',
  type: 'post',
  data,
  isFormData: true,
  loadingFn
});

// 品牌查询 - 正常 + 潜在
export const getAllBrandListService = (data, loadingFn) => commonRequest({
  url: '/sysback/product/collect/getByBrandName',
  type: 'get',
  data,
  loadingFn
});

// 商品新增|准入 - 选择计量单位 - 获取信息列表
export const getUnitInfoListService = (data, loadingFn) => requestToData({
  url: '/sysback/unit/baseQueryList',
  type: 'post',
  data,
  loadingFn
});

// 商品新增|准入 - 选择品牌系列 - 获取下拉option
export const getBrandSeriesOptionsService = (data, target) => requestToData({
  url: '/sysback/addsingleproduct/basicinfo/getBrandSeries',
  type: 'post',
  data,
  isFormData: true,
  target
});

// 商品新增|准入 - 生成助记码 - 获取助记码信息
export const getHelpCodeInfoService = (data, target) => requestToData({
  url: '/sysback/addsingleproduct/basicinfo/getSpuHelpCode',
  type: 'post',
  data,
  target
});

// 商品新增 - 选择标签 - 获取信息列表
export const getTagInfoListService = (data, loadingFn) => requestToData({
  url: '/sysback/addsingleproduct/basicinfo/getPagerByLabel',
  type: 'post',
  data,
  isFormData: true,
  loadingFn
});

// 商品中心 - 修改表单管理 - 单据表尾字段信息获取
export const getFooterFieldsService = (data, target) => requestToData({
  url: '/sysback/product/update/record/get4FormDetail',
  type: 'post',
  data,
  isFormData: true,
  target
});

// 商品中心 - 商品管理 - 停启用和上下架处理 - 全集团实物库存数
export const getPhysicalStockListService = (data, loadingFn) => requestToData({
  url: '/sysback/stock/getPhysicalStockList',
  type: 'get',
  data,
  loadingFn
});

// 商品中心 - 商品管理 - 停启用和上下架处理 - 全集团销售占用数
export const getSaleOccListService = (data, loadingFn) => requestToData({
  url: '/sysback/stock/getSaleOccList',
  type: 'get',
  data,
  loadingFn
});

// 商品中心 - 商品管理 - 停启用和上下架处理 - 全集团采购在途数; 全集团转货在途数
export const getOnWayOrderListService = (data, loadingFn) => requestToData({
  url: '/sysback/stock/getOnWayOrderList',
  type: 'get',
  data,
  loadingFn
});

// 商品中心 - 商品管理 - 停启用、上下架管理 - 处理页 - 替代商品查询
export const searchReplaceProductsService = (data, loadingFn) => requestToData({
  url: '/sysback/finish/sku/enable/list/getReplaceSkuPager',
  type: 'post',
  data,
  loadingFn
});

// 商品中心 - 获取跳转OA页面接口
export const getToSkipOAUrlService = (data, loadingFn) => requestToData({
  url: `/sysback/oa/getAuditPageUrl?oaRequestId=${data.oaRequestId}`,
  type: 'post',
  data,
  loadingFn
});

// 商品中心 - 表单查询 - 获取品牌集合
export const getFormBrandListService = (data, loadingFn) => commonRequest({
  url: '/sysback/product/collect/getPagerByBrand',
  type: 'post',
  data,
  loadingFn,
  isFormData: true
});

// 商品中心 - 客户信息查询
export const queryCustomerListService = (data, loadingFn) => requestToData({
  url: '/sysback/product/collect/queryNewCustomer',
  type: 'post',
  data,
  loadingFn
});

// 商品中心 - 销售属性模板导出
export const exportSaleAttrTemplateService = (data, loadingFn) => commonRequest({
  url: '/sysback/product/addSku/basicInfo/exportSaleAttrTemplate',
  type: 'post',
  data,
  loadingFn,
  isExport: true
});

// 商品中心 - 临采商品 - 列表查询
export const queryTemporaryGoodsService = (data, loadingFn) => commonRequest({
  url: '/sysback/product/collect/getCollectList',
  type: 'post',
  data,
  loadingFn
});

// 商品中心 - 四级类查询
export const queryFinalCategoryService = (data, loadingFn) => commonRequest({
  url: `/sysback/choose/category/getCategoryListByKey?key=${data.key}`,
  type: 'post',
  data,
  loadingFn
});

// 商品中心 - 供应商查询(有权限)
export const querySupplierService = (data, loadingFn) => commonRequest({
  url: '/sysback/supplier/maininfo/list/getPagerSupplierMainInfo',
  type: 'post',
  data,
  loadingFn
})

// 商品中心 - 准入商品 - 获取系列集合
export const getSpuRelSeriesInfoService = (data, loadingFn) => commonRequest({
  url: '/sysback/addsingleproduct/basicinfo/getSpuRelSeriesInfo',
  type: 'post',
  data,
  loadingFn
})

// 商品中心 - 商品管理 - SPU管理|SKU管理 - 修改校验
export const checkPermService = (data, loadingFn) => commonRequest({
  url: '/sysback/spu/query/checkPerm',
  type: 'post',
  data,
  loadingFn,
  isFormData: true
})

// 商品中心 - 商品准入管理 - 查询品类下的计量单位
export const getUnitUnderCateService = (data, loadingFn) => commonRequest({
  url: '/sysback/category/productUnitCateRel/getUnitUnderCate',
  type: 'post',
  data,
  loadingFn,
})

// 商品中心 - 设置参照城市 - 获取销售城市
export const getSupplyCityByAreaCodesService = (data, loadingFn) => commonRequest({
  url: '/sysback/supplyinfofromsrcm/getSupplyCityByAreaCodes',
  type: 'post',
  data,
  loadingFn,
  isFormData: true
})

// 商品中心 - 设置参照城市 - 获取供货城市
export const getSupplyProvinceBySupplyNoService = (data, loadingFn) => commonRequest({
  url: '/sysback/supplyinfofromsrcm/getSupplyProvinceBySupplyNo',
  type: 'post',
  data,
  loadingFn,
  isFormData: true
})

// 商品中心 - 设置参照城市 - 获取更新成本价比例的城市信息
export const getPriceRatioByAreaCodeService = (data, loadingFn) => commonRequest({
  url: '/sysback/supplyinfopriceratio/getPriceRatioByAreaCode',
  type: 'post',
  data,
  loadingFn
})
